// import { getAllRoleList, isAccountExist } from '@/api/demo/system';
import { BasicColumn, FormSchema } from '@/components/Table';
import { getmatchCategoryAPI, getdeviceToOwnerAPI } from '@/api/demo/videoList';
import { useI18n } from "@/hooks/web/useI18n";

const { t } = useI18n();
import { h } from 'vue';

const executeNumList = [
  {
    label: '未执行过任务',
    value: '0',
  },
  {
    label: '已执行',
    value: '1',
  },
];
// 表格数据
export const columnsModels: BasicColumn[] = [
  {
    title: t('sys.informaionMatchaing.columns.url'),
    dataIndex: 'url',
    width: 100,
    customRender: ({ text, record }) => {
      return h(
        'a',
        {
          href: text,
          target: '_blank', // 在新标签页中打开链接
        },
        text,
      );
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.title'),
    dataIndex: 'title',
    width: 130,
  },
  {
    title: t('sys.informaionMatchaing.columns.matching'),
    dataIndex: 'matching',
    width: 20,
  },
  {
    title: t('sys.informaionMatchaing.columns.category'),
    dataIndex: 'category',
    width: 50,
  },
  {
    title: t('sys.analysis.columns.status'),
    dataIndex: 'executeNum',
    width: 60,
    customRender: ({ text, record }) => {
      return text == 0 ? '未执行过任务' : '已经执行过任务' + text + '次';
    },
  },
];
export const searchFormSchema: FormSchema[] = [
  {
    field: 'category',
    component: 'ApiSelect',
    label: t('sys.informaionMatchaing.columns.category'),
    defaultValue: '默认',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
    componentProps: {
      resultField: 'data', // 指定返回数据中的数组字段
      api: getmatchCategoryAPI,
      labelField: ' label',
      valueField: 'value',
    },
  },
  {
    field: 'matching',
    component: 'Input',
    label: '匹配度大于',
    defaultValue: '0.4',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
  },
  {
    field: 'executeNum',
    component: 'Select',
    label: t('sys.analysis.columns.status'),
    defaultValue: '0',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
    componentProps: {
      options: executeNumList,
    },
  },
];

export const chatAccountFormSchema: FormSchema[] = [
  {
    field: 'category',
    component: 'ApiSelect',
    label: t('sys.informaionMatchaing.columns.category'),
    defaultValue: '默认',
    colProps: {
      span: 24,
    },
    componentProps: {
      resultField: 'data', // 指定返回数据中的数组字段
      api: getmatchCategoryAPI,
      labelField: ' label',
      valueField: 'value',
    },
    rules: [{ required: true }],
  },
  {
    field: 'content',
    label: '评论内容',
    component: 'Input',
    colProps: { span: 24 },
    defaultValue: '',
    rules: [{ required: true }],
  },
  {
    field: 'Chatcontent',
    label: '私信内容',
    component: 'Input',
    colProps: { span: 24 },
    defaultValue: '',
    rules: [{ required: true }],
  },
  {
    field: 'devices',
    component: 'ApiSelect',
    label: '选择设备',
    defaultValue: [],
    componentProps: {
      resultField: 'data', // 指定返回数据中的数组字段
      api: getdeviceToOwnerAPI,
      labelField: ' label',
      valueField: 'value',
      mode: 'multiple', // 设置为多选模式
      placeholder: '请选择设备',
    },
    required: true,
    colProps: { span: 24 },
  },
];

export const accountFormChatTime: FormSchema[] = [
  {
    field: 'interval',
    component: 'InputNumber',
    label: '间隔时长',
    defaultValue: '',
    rules: [{ required: true }],
  },
  {
    field: 'devices',
    component: 'ApiSelect',
    label: '选择设备',
    defaultValue: [],
    componentProps: {
      resultField: 'data', // 指定返回数据中的数组字段
      api: getdeviceToOwnerAPI,
      labelField: ' label',
      valueField: 'value',
      mode: 'multiple', // 设置为多选模式
      placeholder: '请选择设备,一个设备上限80个视频',
    },
    rules: [{ required: true }],
  },
];
//私信表单设置
export const accountFormChat: FormSchema[] = [
  {
    field: 'advertisementTemplate',
    slot: 'advertisementTemplate',
    label: '广告受众模板',
    defaultValue: '',
  },
  // {
  //   field: 'templateId',
  //   component: 'ApiSelect',
  //   label: '广告受众模板',
  //   defaultValue: '',
  //   colProps: {
  //     span: 24,
  //   },
  //   componentProps: {
  //     api: getAudiencesListAPI, // 指定接口函数
  //     resultField: 'data', // 接口返回的数据字段名
  //     labelField: 'remark', // 选项显示的标签字段名
  //     valueField: 'id', // 选项的值字段名
  //     placeholder: '请选择模板', // 添加提示文本
  //     // onChange: (value) => {
  //     //   // 触发 fetchTemplateDetail 方法
  //     //   fetchTemplateDetail(value);
  //     // },
  //   },
  // },
  {
    field: 'title',
    component: 'Input',
    label: t('sys.informaionMatchaing.columns.title'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
  },
  {
    field: 'content',
    component: 'InputTextArea',
    label: t('sys.configuration.describe'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    componentProps: {
      rows: 3, // 设置文本域的行数
    },
    rules: [{ required: true }],
  },
  {
    field: 'district',
    component: 'Input',
    label:  t('sys.informaionMatchaing.columns.district'),
    defaultValue: '',
    rules: [{ required: true }],
  },
  // {
  //   field: 'age',
  //   component: 'Input',
  //   label:  t('sys.informaionMatchaing.columns.age'),
  //   defaultValue: '',
  //   rules: [{ required: true }],
  // },
  // {
  //   field: 'gender',
  //   component: 'Input',
  //   label:  t('sys.informaionMatchaing.columns.gender'),
  //   defaultValue: '',
  //   rules: [{ required: true }],
  // },
  {
    field: 'audience',
    component: 'Input',
    label:  t('sys.informaionMatchaing.columns.audience'),
    defaultValue: '',
    rules: [{ required: true }],
  },
  {
    field: 'interest',
    component: 'InputTextArea',
    label:  t('sys.informaionMatchaing.columns.interest'),
    defaultValue: '',
    componentProps: {
      rows: 3, // 设置文本域的行数
    },
    rules: [{ required: true }],
  },
  // {
  //   field: 'category',
  //   component: 'ApiSelect',
  //   label: t('sys.informaionMatchaing.columns.category'),
  //   defaultValue: null,
  //   componentProps: {
  //     resultField: 'data', // 指定返回数据中的数组字段
  //     api: getmatchCategoryAPI,
  //     labelField: ' label',
  //     valueField: 'value',
  //   },
  //   rules: [{ required: true }],
  // },
];
